package com.tigerhhzz.demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author tigerhhzz
 * @Date 2024 02 20 10 48
 * 统计访问页面的人数
 **/
@RestController
public class CounterController {

    @Autowired
    StringRedisTemplate redisTemplate;

    @GetMapping("/hello")
    public String count(){

        Long increment = redisTemplate.opsForValue().increment("count-person");
        return "有【"+ increment +"】人访问了这个页面---------";
    }
}
